let user=[{'yq':'yujingqiang','pwa':'888'},
          {'yq':'duxing','pwa':'222'},
          {'yq':'nieyao','pwa':'333'},
          {'yq':'zoujunfeng','pwa':'444'},
          {'yq':'wangjie','pwa':'555'},
          {'yq':'houxing','pwa':'666'},
          {'yq':'linei','pwa':'777'},]
let switchCtn = document.querySelector("#switch-cnt");
    let switchC1 = document.querySelector("#switch-c1");
    let switchC2 = document.querySelector("#switch-c2");
    let switchCircle = document.querySelectorAll(".switch_circle");
    let switchBtn = document.querySelectorAll(".switch-btn");
    let aContainer = document.querySelector("#a-container");
    let bContainer = document.querySelector("#b-container");
    let allButtons = document.querySelectorAll(".submit");
    let getButtons = (e) => e.preventDefault()
    let changeForm = (e) => {
        // 修改类名
        switchCtn.classList.add("is-gx");
        setTimeout(function () {
            switchCtn.classList.remove("is-gx");
        }, 1500)
        switchCtn.classList.toggle("is-txr");
        switchCircle[0].classList.toggle("is-txr");
        switchCircle[1].classList.toggle("is-txr");

        switchC1.classList.toggle("is-hidden");
        switchC2.classList.toggle("is-hidden");
        aContainer.classList.toggle("is-txl");
        bContainer.classList.toggle("is-txl");
        bContainer.classList.toggle("is-z");
    }
    // 点击切换
    let shell = (e) => {
        for (var i = 0; i < allButtons.length; i++)
            allButtons[i].addEventListener("click", getButtons);
        for (var i = 0; i < switchBtn.length; i++)
            switchBtn[i].addEventListener("click", changeForm)
    }
    window.addEventListener("load", shell);
   
//登录验证 //第一个登录框
email();
function email(){
    let name1=document.getElementById('name1');
    let paw=document.getElementById('paw1');
    let but=document.getElementById('btn');
    let spans=document.getElementById('spans');
    let spand=document.getElementById('spand');
        but.onclick=function(){
            for(let i=0;i<user.length;i++){
                if(name1.value==''){
                     spans.innerHTML=`<span class='iconfont icon-cuowu'>
                     </span>用户名不能为空`;
                     spans.style.color='#f35570';
                   }
                   if(paw.value==''){
                    spand.innerHTML=`<span class='iconfont icon-cuowu'>
                    </span>密码不能为空`;
                    spand.style.color='#f35570';
                    return;
                 }
                 if(name1.value===user[i].yq && paw.value===user[i].pwa){
                  window.location.href="../html/guanlixitong.html?username="+name1.value+"&pwd="+paw.value;
                    return;
                 }else {
                  spans.innerHTML=`<span class='iconfont icon-cuowu'>
                   </span>用户名错误`;
                    spand.innerHTML=`<span class='iconfont icon-cuowu'>
                    </span>密码错误`;
                    spans.style.color='#f35570';
                    spand.style.color='#f35570';
                 }
                 name1.onfocus=function(){
                    spans.innerHTML='';
                    name1.value='';
                 }
                 

                 paw.onfocus=function(){
                    spand.innerHTML='';
                    paw.value='';
                 }
         }
      }
    }
    //第二个登录框
email1();
function email1(){
    let name2=document.getElementById('name2');
    let paw2=document.getElementById('paw2');
    let but1=document.getElementById('btn1');
    let sp1=document.getElementById('sp1');
    let sp2=document.getElementById('sp2');
        but1.onclick=function(){
            for(let i=0;i<user.length;i++){
                if(name2.value==''){
                     sp1.innerHTML=`<span class='iconfont icon-cuowu'>
                     </span>用户名不能为空`;
                     sp1.style.color='#f35570';
                   }
                   if(paw2.value==''){
                    sp2.innerHTML=`<span class='iconfont icon-cuowu'>
                    </span>密码不能为空`;
                    sp2.style.color='#f35570';
                    return;
                 }
                 if(name2.value==user[i].yq && paw2.value==user[i].pwa){
                     window.location.href="../html/guanlixitong.html?username="+name2.value+"&pwd="+paw2.value;
                     return;
                   
                 }else {
                    sp1.innerHTML=`<span class='iconfont icon-cuowu'>
                    </span>用户名错误`;
                    sp2.innerHTML=`<span class='iconfont icon-cuowu'>
                    </span>密码错误`;
                    sp1.style.color='#f35570';
                    sp2.style.color='#f35570';
                 }
                 name2.onfocus=function(){
                    sp1.innerHTML='';
                    name2.value='';
                 }

                 paw2.onfocus=function(){
                    sp2.innerHTML='';
                    paw2.value='';
                 }
         }
      }
    }

   
     